module.exports = {
  meta: {
    type: "problem",
    docs: {
      description:
        "避免直接将 DOM 引用（this.$refs.…）存储在实例属性中。例如：this.domRef = this.$refs.leaky;",
    },
    schema: [],
  },

  create(context) {
    return {
      AssignmentExpression(node) {
        if (
          node.left.type === "MemberExpression" &&
          node.left.object.type === "ThisExpression" &&
          node.right.type === "MemberExpression" &&
          node.right.object.type === "MemberExpression" &&
          node.right.object.object.type === "ThisExpression" &&
          node.right.object.property.name === "$refs"
        ) {
          context.report({
            node,
            message: `避免直接将 DOM 引用（this.$refs.${node.right.property.name}）存储在实例属性中。`,
          });
        }
      },
    };
  },
};
